<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>评价管理 - 废物回收管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .evaluation-container {
            max-width: 1200px;
            margin: 2rem auto;
        }
        .stats-card {
            background: white;
            border-radius: 15px;
            padding: 1.5rem;
            margin-bottom: 1rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }
        .evaluation-card {
            background: white;
            border-radius: 15px;
            padding: 1.5rem;
            margin-bottom: 1rem;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
            transition: transform 0.2s;
        }
        .evaluation-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        }
        .rating {
            color: #ffc107;
            font-size: 1.2rem;
        }
        .rating-empty {
            color: #e9ecef;
        }
        .evaluation-meta {
            color: #6c757d;
            font-size: 0.9rem;
        }
        .evaluation-content {
            margin: 1rem 0;
        }
        .evaluation-reply {
            background: #f8f9fa;
            border-radius: 10px;
            padding: 1rem;
            margin-top: 1rem;
        }
        .evaluation-images {
            display: flex;
            gap: 10px;
            margin-top: 1rem;
        }
        .evaluation-image {
            width: 80px;
            height: 80px;
            border-radius: 8px;
            object-fit: cover;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="/resident">
                <i class="fas fa-recycle me-2"></i>废物回收管理系统
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/resident">首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/orders/create">预约回收</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/category/guide">分类指南</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container evaluation-container">
        <!-- 评分统计 -->
        <div class="stats-card mb-4">
            <h5 class="mb-4">评分统计</h5>
            <div class="row align-items-center">
                <div class="col-md-3 text-center">
                    <div style="font-size: 3rem; font-weight: bold; color: #0d6efd;" th:text="${averageRating}">4.8</div>
                    <div class="rating mb-2">
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star"></i>
                        <i class="fas fa-star-half-alt"></i>
                    </div>
                    <div class="text-muted" th:text="${totalEvaluations + '个评价'}">126个评价</div>
                </div>
                <div class="col-md-9">
                    <div class="mb-3">
                        <div class="d-flex align-items-center mb-1">
                            <span class="me-2">5星</span>
                            <div class="progress flex-grow-1" style="height: 8px;">
                                <div class="progress-bar" role="progressbar" th:style="'width: ' + ${fiveStarPercentage} + '%'" style="width: 75%"></div>
                            </div>
                            <span class="ms-2" th:text="${fiveStarCount}">95</span>
                        </div>
                        <div class="d-flex align-items-center mb-1">
                            <span class="me-2">4星</span>
                            <div class="progress flex-grow-1" style="height: 8px;">
                                <div class="progress-bar" role="progressbar" th:style="'width: ' + ${fourStarPercentage} + '%'" style="width: 15%"></div>
                            </div>
                            <span class="ms-2" th:text="${fourStarCount}">19</span>
                        </div>
                        <div class="d-flex align-items-center mb-1">
                            <span class="me-2">3星</span>
                            <div class="progress flex-grow-1" style="height: 8px;">
                                <div class="progress-bar" role="progressbar" th:style="'width: ' + ${threeStarPercentage} + '%'" style="width: 8%"></div>
                            </div>
                            <span class="ms-2" th:text="${threeStarCount}">10</span>
                        </div>
                        <div class="d-flex align-items-center mb-1">
                            <span class="me-2">2星</span>
                            <div class="progress flex-grow-1" style="height: 8px;">
                                <div class="progress-bar" role="progressbar" th:style="'width: ' + ${twoStarPercentage} + '%'" style="width: 2%"></div>
                            </div>
                            <span class="ms-2" th:text="${twoStarCount}">2</span>
                        </div>
                        <div class="d-flex align-items-center">
                            <span class="me-2">1星</span>
                            <div class="progress flex-grow-1" style="height: 8px;">
                                <div class="progress-bar" role="progressbar" th:style="'width: ' + ${oneStarPercentage} + '%'" style="width: 0%"></div>
                            </div>
                            <span class="ms-2" th:text="${oneStarCount}">0</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 评价列表 -->
        <div class="evaluation-list">
            <div class="evaluation-card" th:each="evaluation : ${evaluations}">
                <div class="d-flex justify-content-between align-items-start">
                    <div>
                        <div class="rating">
                            <i class="fas fa-star" th:each="i : ${#numbers.sequence(1, evaluation.rating)}"></i>
                            <i class="far fa-star rating-empty" th:each="i : ${#numbers.sequence(evaluation.rating + 1, 5)}"></i>
                        </div>
                        <div class="evaluation-meta mt-2">
                            <span th:text="${evaluation.orderNumber}">订单号：2024030100001</span>
                            <span class="mx-2">·</span>
                            <span th:text="${evaluation.createTime}">2024-03-01 14:30</span>
                        </div>
                    </div>
                    <div th:if="${evaluation.status == 1}" class="badge bg-success">已回复</div>
                    <div th:if="${evaluation.status == 0}" class="badge bg-secondary">待回复</div>
                </div>
                <div class="evaluation-content" th:text="${evaluation.content}">
                    回收员服务态度很好，准时到达，整个过程很专业。
                </div>
                <div class="evaluation-images" th:if="${evaluation.images != null && evaluation.images.size() > 0}">
                    <img th:each="image : ${evaluation.images}" 
                         th:src="${image}" 
                         class="evaluation-image"
                         onclick="showImage(this.src)">
                </div>
                <div class="evaluation-reply" th:if="${evaluation.reply != null}">
                    <div class="text-primary mb-2">回复：</div>
                    <div th:text="${evaluation.reply}">感谢您的评价，我们会继续保持优质服务！</div>
                </div>
            </div>
        </div>

        <!-- 分页 -->
        <nav aria-label="Page navigation" class="mt-4">
            <ul class="pagination justify-content-center">
                <li class="page-item" th:classappend="${currentPage == 1} ? 'disabled'">
                    <a class="page-link" th:href="@{/evaluation/list(page=${currentPage - 1})}">上一页</a>
                </li>
                <li class="page-item" th:each="page : ${#numbers.sequence(1, totalPages)}"
                    th:classappend="${page == currentPage} ? 'active'">
                    <a class="page-link" th:href="@{/evaluation/list(page=${page})}" th:text="${page}">1</a>
                </li>
                <li class="page-item" th:classappend="${currentPage == totalPages} ? 'disabled'">
                    <a class="page-link" th:href="@{/evaluation/list(page=${currentPage + 1})}">下一页</a>
                </li>
            </ul>
        </nav>
    </div>

    <!-- 图片预览模态框 -->
    <div class="modal fade" id="imageModal" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-body p-0">
                    <img src="" id="modalImage" class="img-fluid">
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.2.3/js/bootstrap.bundle.min.js"></script>
    <script>
        // 图片预览
        function showImage(src) {
            $('#modalImage').attr('src', src);
            $('#imageModal').modal('show');
        }
    </script>
</body>
</html> 